<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="../js/jquery-2.1.1.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
<script type ="text/javascript" src ="../js/jquery.columns-1.1.min.js"></script>
<link id="style" href="../css/clean.css" rel="stylesheet" media="screen">

<script type="text/javascript">

$(document).ready(function() {
	 
	listDiv1();
	setState();
	
	$('#state').on('change',function(){
		var Changestate = $(this).val();
		
		
		 location.href='/mamma/sanghyun/goBoardList.action?state='+Changestate;	  
		
		/*
		$.ajax({
			url : 'goBoardList.action',
			type : 'POST',
			dataType : 'json', 
			data:{state:state},
			success:function(json) {
				boardList = $('#listDiv1').columns({
					data:json.boardList,
					schema: [
						{"header":"번호", "key":"boardNum"},
						{"header":"제목", "key":"title" , "template":'<a href="<s:url value="readBoard.action?boardNum="/>{{boardNum}}">{{title}}</a>'}
					]
				}); 
				var state = json.state;
				$('option[value='+state+']').attr('selected',"selected");
				
			}
		});  */
	});
	
	 $('#write').on('click',gowrite); 
	
	 $('#main').on('click',gomain); 
});
function listDiv1(){
	var state ='<s:property value="state"/>';
	$.ajax({
		url : 'boardList.action',
		type : 'POST',
		dataType : 'json', 
		data:{state:state},
		success:function(json) { 
			boardList = $('#listDiv1').columns({
				data:json.boardList,
				schema: [
					{"header":"번호", "key":"boardNum"},
					{"header":"제목", "key":"title" , "template":'<a href="<s:url value="readBoard.action?boardNum="/>{{boardNum}}">{{title}}</a>'},
					{"header":"작성자", "key":"nickname"},
					{"header":"조회수", "key":"viewCount"}
				]
			}); 
		}
	}); 
}


	
 function gowrite(){
	location.href="writeBoardForm.action";
 }
 
 function gomain(){
		location.href='../jinhyuk/home.action';
	}
 function setState(){
		var state = '<s:property value="state"/>';
			$('option[value='+state+']').attr('selected',"selected");
 }

</script>

</head>
<body>

<h1 style="text-align: center;">[테마게시판]</h1> 
<select id="state" name="memberVo.hometown">
			<option value="서울">서울</option>
			<option value="경기">경기</option>
			<option value="인천">인천</option>
			<option value="강원">강원</option>
			<option value="충남">충남</option>
			<option value="충북">충북</option>
			<option value="대전">대전</option>
			<option value="세종">세종</option>
			<option value="부산">부산</option>
			<option value="울산">울산</option>
			<option value="대구">대구</option>
			<option value="경북">경북</option>
			<option value="경남">경남</option>
			<option value="광주">광주</option>
			<option value="전북">전북</option>
			<option value="전남">전남</option>
			<option value="제주">제주</option>
		</select>


<div id="listDiv1" style="margin:0 auto; width: 900px;">
</div>

<form style="text-align: center;" >
<input type="button" id="write" value="글쓰기"> <input type="button" id="main" value="메인으로">

</form>
</body>
</html>